let count = 10; //每一页的条数
let page = 1; //当前页
let pageArr = [10, 12, 15,20];
let maxpage
//增加


//查询
getData();
function getData() {

  $.ajax({
    url: '/baogao/query',
    data: {
      count: count,
      page: page
    },
    success: (res) => {
      // console.log(res);
      if (res.error) {
        console.log(res.error)
      } else {
        //列表渲染
        $('.mtbody').html('');
        $(res.data).each((i, item) => {
          $('.mtbody').append(`
                        <tr data-id="${item.g_id}">
                        <td><div>
                        <p>日期</p>
                        <p>${item.g_date.slice(0, 10)}</p>
                        </div></td>
                        <td>
                        <div>
                        <p>标题</p>
                        <p>${item.g_baogao}</p>
                        </div></td>
                        <td>
                        <div>
                        <p>提交人员</p>
                        <p>${item.g_name}</p>
                        </div></td>
                        <td><div>
                        <p>日报类型</p>
                        <p>${item.g_leixing}</p>
                        </div></td>
                        <td><div>
                        <p>抄送人员</p>
                        <p>${item.g_chaosong}</p>
                        </div></td>
                        
                        <td class='btnb'>
                        <span class='iconfont icon-youjiantou'>详情</span></td>
                        </tr>
                    `)
        })

        $('#myli').html('')
        maxpage = Math.ceil((res.total / count))
        for (let i = 1; i <= Math.ceil((res.total / count)); i++) {
          if (page == i) {
            $('#myli').append(`
                                <a id="a" class="active new_page" href="javascript:;">${i}</a>
                                        `)
          } else {
            $('#myli').append(`
                        <a href="javascript:;" id="a">${i}</a>
                       `)
          }
        }
      }
    }
  })
}
getData1();
function getData1() {
  $.ajax({
    url: '/baogao1/query',
    data: {
      count: count,
      page: page
    },
    success: (res) => {
      // console.log(res);
      if (res.error) {
        console.log(res.error)
      } else {
        //列表渲染
        $('.ttian').html('');
        $(res.data).each((index, item) => {
          $('.ttian').append(`
                    <tr data-id1="${item.t_id}">
                        <td>${item.t_name}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_zhouyi}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_zhouer}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_zhousan}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_zhousi}</td>
                        <td><span class='iconfont icon-yk_gantanhao_fill
                        '></span>${item.t_zhouwu}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_zhouliu}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_zhouri}</td>
                        <td>${item.t_wancheng}</td>
                    </tr>
                    `);
        });
        $('.tzhou').html('');
        $(res.data).each((index, item) => {
          $('.tzhou').append(`
                    <tr data-id1="${item.t_id}">
                        <td>${item.t_name}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_zhouone}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_zhoutwo}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_zhouthree}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_zhoufour}</td>
                        <td><span class='iconfont icon-yk_gantanhao_fill'></span>${item.t_zhoufix}</td>
                        <td>${item.t_wancheng}</td>
                    </tr>
                    `);
        });
        $('.tyue').html('');
        $(res.data).each((index, item) => {
          $('.tyue').append(`
                    <tr data-id1="${item.t_id}">
                        <td>${item.t_name}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yueyi}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yueer}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yuesan}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yuesi}</td>
                        <td><span class='iconfont icon-yk_gantanhao_fill
                        '></span>${item.t_yuewu}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yueliu}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yueqi}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yueba}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yuejiu}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yueshi}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yueshiyi}</td>
                        <td><span class='iconfont icon-duigouxiao'></span>${item.t_yueshier}</td>
                        <td>${item.t_wancheng}</td>
                    </tr>
                    `);
        });
        //页码渲染
        /*
        3   1
        5   1
        6   2
        10  2
        11  3
        total    Math.ceil(total/count)
        */
        $('#myli').html('')
        maxpage = Math.ceil((res.total / count))
        for (let i = 1; i <= Math.ceil((res.total / count)); i++) {
          if (page == i) {
            $('#myli').append(`
                        <a id="a" class="active new_page" href="javascript:;">${i}</a>
                                `)
          } else {
            $('#myli').append(`
                <a href="javascript:;" id="a">${i}</a>
               `)
          }
        }
      }
    }
  })
}
